﻿//----------------------------------------------------------------------------
// Copyright (c) 2002-2013 Microsoft Corporation
//
// This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
// copy of the license can be found in the License.html file at the root of this distribution. 
// By using this source code in any fashion, you are agreeing to be bound 
// by the terms of the Apache License, Version 2.0.
//
// You must not remove this notice, or any other, from this software.
//----------------------------------------------------------------------------

namespace MSDN.FSharp.Charting
    
open System
open System.Drawing
open System.Collections.Generic
open System.Windows.Forms
open System.Windows.Forms.DataVisualization


module ChartStyles =

    // --------------------------------------------------------------------------------------
    // [AUTOGENERATED]: Enumerations for custom attribute types

    /// Specifies the plot area shape in Radar and Polar charts.
    type AreaDrawingStyle = 
        | Circle = 0
        | Polygon = 1

    /// Specifies the placement of the data point label.
    type BarLabelStyle = 
        | Outside = 0
        | Left = 1
        | Right = 2
        | Center = 3

    /// Specifies the text orientation of the axis labels in Radar
    /// and Polar charts.
    type CircularLabelStyle = 
        | Circular = 0
        | Horizontal = 1
        | Radial = 2

    /// Specifies the drawing style of data points.
    type DrawingStyle = 
        | Cylinder = 0
        | Emboss = 1
        | LightToDark = 2
        | Wedge = 3
        | Default = 4

    /// Specifies whether series of the same chart type are drawn
    /// next to each other instead of overlapping each other.
    type DrawSideBySide = 
        | Auto = 0
        | True = 1
        | False = 2

    /// Specifies the value to be used for empty points.
    type EmptyPointValue = 
        | Average = 0
        | Zero = 1

    /// Specifies the appearance of the marker at the center value
    /// of the error bar.
    type ErrorBarCenterMarkerStyle = 
        | None = 0
        | Line = 1
        | Square = 2
        | Circle = 3
        | Diamond = 4
        | Triangle = 5
        | Cross = 6
        | Star4 = 7
        | Star5 = 8
        | Star6 = 9
        | Star10 = 10

    /// Specifies the visibility of the upper and lower error values.
    type ErrorBarStyle = 
        | Both = 0
        | UpperError = 1
        | LowerError = 2

    /// Specifies how the upper and lower error values are calculated
    /// for the center values of the ErrorBarSeries.
    type ErrorBarType = 
        | FixedValue = 0
        | Percentage = 1
        | StandardDeviation = 2
        | StandardError = 3

    /// Specifies the 3D drawing style of the Funnel chart type.
    type Funnel3DDrawingStyle = 
        | CircularBase = 0
        | SquareBase = 1

    /// Specifies the data point label placement of the Funnel chart
    /// type when the FunnelLabelStyle is set to Inside.
    type FunnelInsideLabelAlignment = 
        | Center = 0
        | Top = 1
        | Bottom = 2

    /// Specifies the data point label style of the Funnel chart type.
    type FunnelLabelStyle = 
        | Inside = 0
        | Outside = 1
        | OutsideInColumn = 2
        | Disabled = 3

    /// Placement of the data point label in the Funnel chart
    /// when FunnelLabelStyle is set to Outside or OutsideInColumn.
    type FunnelOutsideLabelPlacement = 
        | Right = 0
        | Left = 1

    /// Specifies the style of the Funnel chart type.
    type FunnelStyle = 
        | YIsWidth = 0
        | YIsHeight = 1

    /// Specifies the label position of the data point.
    type LabelStyle = 
        | Auto = 0
        | Top = 1
        | Bottom = 2
        | Right = 3
        | Left = 4
        | TopLeft = 5
        | TopRight = 6
        | BottomLeft = 7
        | BottomRight = 8
        | Center = 9

    /// Specifies the Y value to use as the data point
    /// label.
    type LabelValueType = 
        | High = 0
        | Low = 1
        | Open = 2
        | Close = 3

    /// Specifies the marker style for open and close values.
    type OpenCloseStyle = 
        | Triangle = 0
        | Line = 1
        | Candlestick = 2

    /// Specifies the drawing style of the data points.
    type PieDrawingStyle = 
        | Default = 0
        | SoftEdge = 1
        | Concave = 2

    /// Specifies the label style of the data points.
    type PieLabelStyle = 
        | Disabled = 0
        | Inside = 1
        | Outside = 2

    /// Specifies the drawing style of the Polar chart type.
    type PolarDrawingStyle = 
        | Line = 0
        | Marker = 1

    /// Specifies the 3D drawing style of the Pyramid chart type.
    type Pyramid3DDrawingStyle = 
        | CircularBase = 0
        | SquareBase = 1

    /// Specifies the placement of the data point labels in the
    /// Pyramid chart when they are placed inside the pyramid.
    type PyramidInsideLabelAlignment = 
        | Center = 0
        | Top = 1
        | Bottom = 2

    /// Specifies the style of data point labels in the Pyramid chart.
    type PyramidLabelStyle = 
        | Inside = 0
        | Outside = 1
        | OutsideInColumn = 2
        | Disabled = 3

    /// Specifies the placement of the data point labels in the
    /// Pyramid chart when the labels are placed outside the pyramid.
    type PyramidOutsideLabelPlacement = 
        | Right = 0
        | Left = 1

    /// Specifies whether the data point value represents a linear height
    /// or the surface of the segment.
    type PyramidValueType = 
        | Linear = 0
        | Surface = 1

    /// Specifies the drawing style of the Radar chart.
    type RadarDrawingStyle = 
        | Area = 0
        | Line = 1
        | Marker = 2

    /// Specifies whether markers for open and close prices are displayed.
    type ShowOpenClose = 
        | Both = 0
        | Open = 1
        | Close = 2

    // [/AUTOGENERATED]
    // --------------------------------------------------------------------------------------


    // Background helpers
    [<RequireQualifiedAccess>]
    type Background = 
        | EmptyColor
        | Gradient of Color * Color * Charting.GradientStyle
        | Solid of Color

    let inline applyBackground (obj:^T) back =
        match back with 
        | Background.EmptyColor ->
            (^T : (member set_BackColor : Color -> unit) (obj, Color.Empty))
        | Background.Solid color ->
            (^T : (member set_BackColor : Color -> unit) (obj, color))
        | Background.Gradient(first, second, style) ->
            (^T : (member set_BackColor : Color -> unit) (obj, first))
            (^T : (member set_BackSecondaryColor : Color -> unit) (obj, second))
            (^T : (member set_BackGradientStyle : Charting.GradientStyle -> unit) (obj, style))

    // Default font used when creating styles, titles, and legends
    let DefaultFont = 
        new Font("Calibri", 9.0f, FontStyle.Regular)

    // Type used for defining defaults
    type internal ChartStyleDefault =
        { ChartType:Charting.SeriesChartType option; ParentType:Type option; PropertyName:string; PropertyDefault:obj }

    // Definition of defaults for the chart
    let internal PropertyDefaults = 
        [ // Define type specific defaults
          { ChartStyleDefault.ChartType = None; ParentType = Some(typeof<Charting.LabelStyle>); PropertyName="Font"; PropertyDefault=(box (new Font("Arial Narrow", 10.0f, FontStyle.Regular))) }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Line); ParentType = Some(typeof<Charting.Series>); PropertyName="BorderWidth"; PropertyDefault=(box 2) }
          // Define series ToolTip defaults
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Line); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Spline); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Bar); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Column); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Area); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.StackedBar); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.StackedColumn); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.StackedArea); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.StackedBar100); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.StackedColumn100); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.StackedArea100); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.SplineArea); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Range); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, High=#VALY1, Low=#VALY2") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.RangeBar); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "Y=#VALX, High=#VALY1, Low=#VALY2") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.RangeColumn); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, High=#VALY1, Low=#VALY2") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.SplineRange); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, High=#VALY1, Low=#VALY2") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Point); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.PointAndFigure); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, High=#VALY1, Low=#VALY2") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.ThreeLineBreak); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.StepLine); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Pie); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Doughnut); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.BoxPlot); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "Lower Whisker=#VALY1, Upper Whisker=#VALY2, Lower Box=#VALY3, Upper Box=#VALY4") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Candlestick); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "High=#VALY1, Low=#VALY2, Open=#VALY3, Close=#VALY4") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Stock); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "High=#VALY1, Low=#VALY2, Open=#VALY3, Close=#VALY4") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Renko); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Bubble); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VALY1, Size=#VALY2") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.ErrorBar); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VALY1, Lower=#VALY2, Upper=#VALY3") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Funnel); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Pyramid); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Kagi); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "X=#VALX, Y=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Polar); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "Angle=#VALX, Distance=#VAL") }
          { ChartStyleDefault.ChartType = Some(Charting.SeriesChartType.Radar); ParentType = Some(typeof<Charting.Series>); PropertyName="ToolTip"; PropertyDefault=(box "Point=#VALX, Distance=#VAL") }
          // Define global defaults
          { ChartStyleDefault.ChartType = None; ParentType = None; PropertyName="Font"; PropertyDefault=(box DefaultFont) } ]
